package com.company.project.controller;

import com.company.project.common.aop.annotation.LogAnnotation;
import com.company.project.common.utils.DataResult;
import com.company.project.entity.CallbackEntityVo1;
import com.company.project.entity.CallbackEntityVo2;
import com.company.project.entity.SysSmscodeEntity;
import com.company.project.service.HomeService;
import com.company.project.service.HttpSessionService;
import com.company.project.service.TSeatsService;
import com.company.project.vo.req.HomeTJReqVO;
import com.company.project.vo.resp.HomeRespVO;
import com.company.project.vo.resp.HomeTJRespVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;


/**
 * 首页
 *
 * @author wenbin
 * @version V1.0
 * @date 2020年3月18日
 */
@RestController
@RequestMapping("/sys")
@Api(tags = "首页数据")
public class HomeController {
    @Resource
    private HomeService homeService;
    @Resource
    private HttpSessionService httpSessionService;
    @Autowired
    private TSeatsService tSeatsService;

    @GetMapping("/home")
    @ApiOperation(value = "获取首页数据接口")
    @LogAnnotation(title = "获取首页数据接口", action = "home")
    public DataResult getHomeInfo() {
        //通过access_token拿userId
        String userId = httpSessionService.getCurrentUserId();
        DataResult result = DataResult.success();
        HomeRespVO homeInfo = homeService.getHomeInfo(userId);

        result.setData(homeInfo);
        return result;
    }
    @PostMapping("/home/jfcsqs")
    @ApiOperation(value = "获取首页统计数据接口")
    public DataResult getJfcsqs(@RequestBody HomeTJReqVO vo) {
        return homeService.getJfcsqs(vo);
    }

    @PostMapping("/home/wdkhTJ")
    @ApiOperation(value = "获取我的客户统计接口")
    public DataResult getWdkhTJ(@RequestBody HomeTJReqVO vo) {
        return homeService.getWdkhTJ(vo);
    }
    @PostMapping("/home/tongji")
    @ApiOperation(value = "获取首页统计数据接口")
    public DataResult getTongji(@RequestBody HomeTJReqVO vo) {
        return homeService.getHomeTongji(vo.getTime());
    }
    @GetMapping("/home/data")
    @ApiOperation(value = "获取首页数据接口")
    @LogAnnotation(title = "API获取首页数据接口", action = "home/data")
    public DataResult getHomeDataInfo(String account) {
        //通过access_token拿userId
        String userId = httpSessionService.getCurrentUserId();
        DataResult result = DataResult.success();
        HomeRespVO homeInfo = homeService.getHomeInfo(userId);

        result.setData(homeInfo.getHwtj());
        return result;
    }
    @GetMapping("/home/tseatsData")
    @ApiOperation(value = "获取坐席占比接口")
    public DataResult getTseatsData() {
        return  homeService.getTseatsData();
    }
    @GetMapping("/home/twdkhData")
    @ApiOperation(value = "获取客户占比接口")
    public DataResult getTwdkhData() {
        return  homeService.getTwdkhData();
    }
    @PostMapping("callbak/dxline")
    @LogAnnotation(title = "有效回调", action = "callbak")
    public DataResult notifyurl(@RequestBody CallbackEntityVo1 vo) {
        tSeatsService.notifyurl1(vo);
        return DataResult.success();
    }
    @PostMapping("callbak/dyline")
    @LogAnnotation(title = "坐席", action = "回调")
    public DataResult dyline(@RequestBody  CallbackEntityVo2 vo) {
        tSeatsService.dyline(vo);
        return DataResult.success("",0000);
    }
}
